﻿<%@ WebHandler Language="C#" Class="weekplan" %>

using System;
using System.Web;
using TSqlServer;

public class weekplan : IHttpHandler
{
    
    public void ProcessRequest (HttpContext context) {

        string inman = context.Request["myuid"].ToString();
        string strcdate = context.Request["cdate"].ToString();
        DateTime cDate = System.Convert.ToDateTime(strcdate);
        
        context.Response.ContentType = "text/plain";
        context.Response.Write(DrawPlan(cDate,inman));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

    private string DrawPlan(DateTime curDate,string inman)
    {
        DateTime WeekBDate = TDateTime.GetBDateOfWeek(curDate);
        DateTime WeekEDate = TDateTime.GetEDateOfWeek(curDate);
        int WeekNum = TDateTime.GetWeekNum(curDate);

        string plan = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"96%\"><tr><td>";

        plan += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";    
        plan += "<tr height=\"20\">";            
        plan += "<td background=\"./images/cale/s1_t1.gif\" width=\"10\"></td>";            
        plan += "<td background=\"./images/cale/s1_t2.gif\" align=\"center\">";            
        //-----
        plan += DrawWeekHead(curDate, WeekBDate, WeekEDate);
        //-----
        plan += "</td>";                
        plan += "<td background=\"./images/cale/s1_t3.gif\" width=\"10\"></td>";                
        plan += "</tr>";                
        plan += "<tr>";                    
        plan += "<td background=\"./images/cale/s1_l2.gif\" width=\"10\"></td>";                    
        plan += "<td bgcolor=\"#E8EEF7\">";
        //-----
        plan += DrawWeekContent(curDate, WeekBDate, WeekEDate,inman);
        //-----
        plan += "</td>";                            
        plan += "<td background=\"./images/cale/s1_r2.gif\" width=\"10\"></td>";                            
        plan += "</tr>";                            
        plan += "<tr height=\"9\">";                            
        plan += "<td background=\"./images/cale/s1_b1.gif\" width=\"10\"></td>";                            
        plan += "<td background=\"./images/cale/s1_b2.gif\"></td>";                            
        plan += "<td background=\"./images/cale/s1_b3.gif\" width=\"10\"></td>";                            
        plan += "</tr>";                            
        plan += "</table>";                            
                        
        plan += "</td></tr></table>";

        return plan;    
    }

    private string DrawWeekHead(DateTime cdate, DateTime wbdate, DateTime wedate)
    {
        string result = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";

        result += "<td width=\"4%\"></td>";

        DateTime dtTemp = wbdate;
        while (dtTemp <= wedate)
        {
            string weekname = TDateTime.GetWeekName(dtTemp.DayOfWeek.ToString());
            if ((weekname == "周六") || (weekname == "周日"))
            {
                result += "<td width=\"13%\" class=\"cale_td_title\">";
            }
            else
            {
                result += "<td width=\"14%\" class=\"cale_td_title\">";
            }
            
            result += dtTemp.ToString("yy-MM-dd") + "&nbsp;";
            result += weekname;
            result += "</td>";

            dtTemp = dtTemp.AddDays(1);
        }
        
        result += "</tr></table>";
        
        return result;
    }

    private string DrawWeekContent(DateTime cdate, DateTime wbdate, DateTime wedate, string inman)
    {
        string result = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";

        foreach (string stime in TDateTime.plantimes)
        {
            //第一行
            result += "<tr class=\"cale_tr_content\">";
            if (stime != "23:00")
            {
                result += "<td width=\"4%\" rowspan=\"2\" class=\"cale_td_content_left\">" + stime + "</td>";
            }
            else
            {
                result += "<td width=\"4%\" rowspan=\"2\" class=\"cale_td_content_leftbottom\">" + stime + "</td>";
            }
            
            DateTime dtTemp = wbdate;
            while (dtTemp <= wedate)
            {
                result += DrawCell(dtTemp,stime,1,inman);
                dtTemp = dtTemp.AddDays(1);
            }
            result += "</tr>";

            //第二行
            result += "<tr class=\"cale_tr_content\">";
            dtTemp = wbdate;
            while (dtTemp <= wedate)
            {
                result += DrawCell(dtTemp, stime, 2,inman);
                dtTemp = dtTemp.AddDays(1);
            }
            result += "</tr>";
        }

        result += "</table>";
        
        return result;
    }

    private string DrawCell(DateTime today, string nowtime, int cellnum,string inman)
    {
        string result = "";

        string cellname = today.ToString("yy-MM-dd") + "_" + nowtime + "_" + cellnum.ToString();
        cellname = cellname.Replace(":", "_");
        cellname = cellname.Replace("-", "_");
        
        //获得系统当前日期和时间
        DateTime dtDate = System.DateTime.Today;
        string sDate = dtDate.ToString("yyyy-MM-dd");
        DateTime dtTime = System.DateTime.Now;
        string sTime = dtTime.ToString("HH:mm");

        string weekname = TDateTime.GetWeekName(today.DayOfWeek.ToString());

        if (cellnum == 1)   //虚线行
        {
            switch (weekname)
            {
                case "周一":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('"+cellname+"')\" width=\"14%\" class=\"cale_td_content1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11 cale_td_content_time\">";
                        }
                    }
                    break;
                case "周二":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11 cale_td_content_time\">";
                        }
                    }
                    break;
                case "周三":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11 cale_td_content_time\">";
                        }
                    }
                    break;
                case "周四":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11 cale_td_content_time\">";
                        }
                    }
                    break;
                case "周五":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content11 cale_td_content_time\">";
                        }
                    }
                    break;
                case "周六":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content11 cale_td_content_time\">";
                        }
                    }
                    break;
                case "周日":
                    if (today != dtDate)
                    {
                        result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right1\">";
                    }
                    else
                    {
                        if(nowtime.Substring(0,2)!=sTime.Substring(0,2))
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right11\">";
                        }
                        else
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right11 cale_td_content_time\">";
                        }
                    }
                    break;
            }
        }

        if (cellnum == 2)   //实线行
        {
            if (nowtime != "23:00")
            {
                switch (weekname)
                {
                    case "周一":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周二":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周三":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周四":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周五":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content22 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周六":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content22 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周日":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right2\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right22\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right22 cale_td_content_time\">";
                            }
                        }
                        break;
                }
            }
            else//最后一行
            {
                switch (weekname)
                {
                    case "周一":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周二":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周三":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周四":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周五":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"14%\" class=\"cale_td_content33 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周六":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content33 cale_td_content_time\">";
                            }
                        }
                        break;
                    case "周日":
                        if (today != dtDate)
                        {
                            result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right3\">";
                        }
                        else
                        {
                            if (nowtime.Substring(0, 2) != sTime.Substring(0, 2))
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right33\">";
                            }
                            else
                            {
                                result += "<td id=\"" + cellname + "\" onclick=\"NewEvent('" + cellname + "','" + today.ToString("yy-MM-dd") + "','" + nowtime + "','" + cellnum.ToString() + "')\" onblur=\"blurCell('" + cellname + "')\" width=\"13%\" class=\"cale_td_content_right33 cale_td_content_time\">";
                            }
                        }
                        break;
                }
            }
        }

        result += TDateTime.GetPlans(inman,today,nowtime,cellnum)+"</td>";
        
        return result;
    }

    private string GetPlans(string inman, DateTime plandate, string plantime, int plantimenum)
    {
        string result = "";

        string sSql = "select plancontent,planmans from t_plan where inman='" + inman + "' and plandate='" + plandate.ToString("yyyy-MM-dd") + "' and plantime='" + plantime + "' and plantimenum=" + plantimenum.ToString() + " order by iid desc";
        TSqlDBReader oReader = new TSqlDBReader(sSql);
        while (oReader.FDataReader.Read())
        {
            result += "<div>·";
            result += oReader.FDataReader.GetValue(0).ToString();
            if (oReader.FDataReader.GetValue(1).ToString()!="")
            {
                result += "(" + oReader.FDataReader.GetValue(1).ToString() + ")";
            }
            result += "</div>";
        }
        oReader.Free();

        if (result == "")
        {
            result = "&nbsp;";
        }
        
        return result;
    }
}